Skip to content

Skip unnecessary analysis catalog queries and isolate team-scoped cache entries - #142

Merged
jackshim415 merged 2 commits into
mainfrom
jackshim415/db-free-analysis-cache-hits
Nov 22, 2026
Merged

jackshim415 merged 2 commits into
mainfrom
jackshim415/db-free-analysis-cache-hits

Conversation

@jackshim415

Copy link
Copy Markdown
Contributor

What changed

Load the analysis team and tournament catalogs only on demand. A warm aggregate lookup does not need to fetch the catalog or recalculate the metric. Notes and breakdown caches now include the viewer’s current team so changing teams cannot reuse a response containing names visible to the former team.

This is a first step toward Redis-only warm requests (LVT-375). It deliberately retains the PostgreSQL cache-registration check required by Worker invalidation and does not change auth or key counters.

Areas affected

  • Server

Contracts and data

  • No API or database contract change
  • Tenant and source-team visibility reviewed
  • No credentials, production data, or private scouting notes included

Verification

Node 22.20.0: npm run build, npm run typecheck, npm run typecheck:test, npm run lint (0 errors; 79 existing warnings), and DATABASE_URL=<local unit test URL> npm run test:coverage:unit (1,462 tests passed, 100% per-file coverage). Structure and diff checks passed. Regression tests assert no catalog/compute calls on a warm aggregate and no prior-team names served after membership changes.

Deployment

No configuration or migration. Only the two name-bearing analysis caches get new keys; their first request after rollout may miss.

Load catalog dependencies only when creating cache entries, and key name-bearing responses by the viewer’s current team. Retain the database check used by Worker invalidation.

Refs: LVT-375
@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-22T16:28:09.375875Z
We couldn’t complete this review. Comment @codex review to try again.
37cfc45 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@railway-app

railway-app Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

🚅 Deployed to the lovat-pr-142 environment in lovat

Service Status Web Updated
api ✅ Success (View Logs) Web Nov 22, 2026 at 4:56 pm UTC
worker ⏭️ Skipped (View Logs) Nov 22, 2026 at 4:55 pm UTC
website 😴 Sleeping (View Logs) Web Nov 22, 2026 at 4:40 pm UTC
dashboard 😴 Sleeping (View Logs) Web Nov 22, 2026 at 4:38 pm UTC
learn 😴 Sleeping (View Logs) Web Nov 22, 2026 at 4:35 pm UTC
2 services not affected by this PR
  • worker
  • support

@railway-app
railway-app Bot temporarily deployed to lovat / lovat-pr-142 November 22, 2026 16:28 Destroyed
@github-actions

Copy link
Copy Markdown
Contributor

📱 Connect your app to this PR deployment

Scan a QR code to use this PR's Server API. Worker changes use the same API;
the Worker has no public app endpoint.

Server URL: https://api-lovat-pr-142.up.railway.app

Lovat Collection

QR code — Lovat Collection

lovat-collection://set-url?u=https%3A%2F%2Fapi-lovat-pr-142.up.railway.app

Lovat Dashboard

QR code — Lovat Dashboard

com.frc8033.lovatdashboard:///set-url?u=https%3A%2F%2Fapi-lovat-pr-142.up.railway.app

@github-actions

github-actions Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Lovat AI review

Status: completed · Model: z-ai/glm-5.3-flash · Findings: 0

Reviewed commit: 28def3f65bce3381188d93063f63cbb62147e713

Critical: 0 · High: 0 · Medium: 0 · Low: 0

Overall assessment

This PR converts import-time catalog queries into lazy, failure-tolerant snapshots and adds viewer-team isolation to the analysis cache key for the two handlers that expose scout names. The lazy loader correctly resets its snapshot on failure so a transient catalog error is not cached permanently, and the viewer-team key fragment is applied before caching so cross-team leakage via a shared cache entry is prevented. The call-site updates and test mocks are consistent with the new exported names and signatures. No concrete defect is evidenced in the changed lines.

No high-confidence issues were found in the reviewed changes.

Review details

  • Review batches: 1
  • Diff characters reviewed: 15,436
  • Tokens: 7,076 prompt + 1,638 completion
  • Estimated inference cost: $0.0013

Limitations

  • The reviewer examined only changed lines and their diff context, not the whole repository.

@railway-app
railway-app Bot temporarily deployed to lovat / lovat-pr-142 November 22, 2026 16:55 Destroyed
@jackshim415
jackshim415 merged commit a25888f into main Nov 22, 2026
29 checks passed

This branch was successfully deployed

No deployments
lovat / lovat-pr-142 — 28def3f6 Deployed Nov 22, 2026 by railway-app[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant